<?php

namespace app\model;

use think\Model;

class Odds extends Model
{
    // 获取所有概率
    public function all()
    {
        $man = $this->where('key', 'man')->value('odds');
        $woman = $this->where('key', 'woman')->value('odds');

        return [
            'man' => $man,
            'woman' => $woman,
        ];
    }

    // 设定概率
    public function setman($odds)
    {
        $data = $this->where('key', 'man')->find();
        $data->odds = $odds;
        $data->save();
    }

    // 设定概率
    public function setwoman($odds)
    {
        $data = $this->where('key', 'woman')->find();
        $data->odds = $odds;
        $data->save();
    }
}
